<?php
/**
 * User: Administrator
 * Created Time: 2017/1/15 19:11
 * Description :
 */

namespace App\services;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

class ThirdApiService
{
    /**
     * @var Client
     */
    public $client;

    public $url='http://www.baidu.com';

    public $nexmo_url="https://rest.nexmo.com/sms/json";

    public $kuai_100="http://www.kuaidi100.com/autonumber/autoComNum?text=[单号]";

    public $kuai_transportation_details="http://www.kuaidi100.com/query?type=[comCode]&postid=[单号]&id=1&valicode=&temp=[时间戳]";

//curl -X POST  https://rest.nexmo.com/sms/json \
//-d api_key=3b32e905 \
//-d api_secret=f3ddff22cf91f803 \
//-d to=8613128107501 \
//-d from="NEXMO" \
//-d text="Hello from Nexmo"

    public function __construct(Client $client)
    {
        $this->client=$client;
    }

    public function getContent(){
        return $this->client->get($this->url)->getBody();
    }


    public function sendMSM(){
        $request= new Request('GET',$this->nexmo_url,[],[
            'query'=>[
                'api_key'=>'3b32e905',
                'api_secret'=>'f3ddff22cf91f803',
                'to'=>"8613128107501",
                'from'=>"NEXMO",
                'text'=>"Hello from Nexmo"
            ],
        ]);
//        $this->client->send($request);

//        $this->client->request()
        $promise = $this->client->sendAsync($request)->then(function ($response) {
            echo 'I completed! ' . $response->getBody();
        });

    }




}